home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Macintosh Easy Open / Documentation / Developer / Interfaces / CIncludes / StandardFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  13.6 KB  |  418 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        StandardFile.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Built by:            anonymous
  8.                  From:                StandardFile.i, revision 2, dated 2/25/94
  9.                  With Interfacer:    1.1d4e2
  10.  
  11.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  12.                  List the version information from above in Problem Description.
  13.  
  14. */
  15.  
  16. #ifndef __STANDARDFILE__
  17. #define __STANDARDFILE__
  18.  
  19. #ifndef __TYPES__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25. /*    #include <MixedMode.h>                                        */
  26. /*        #include <Traps.h>                                        */
  27. #endif
  28. #ifndef __DIALOGS__
  29.  
  30. #ifndef __DIALOGS__
  31. #include <Dialogs.h>
  32. #endif
  33. /*    #include <Windows.h>                                        */
  34. /*        #include <Quickdraw.h>                                    */
  35. /*            #include <QuickdrawText.h>                            */
  36. /*                #include <IntlResources.h>                        */
  37. /*        #include <Events.h>                                        */
  38. /*            #include <OSUtils.h>                                */
  39. /*        #include <Controls.h>                                    */
  40. /*            #include <Menus.h>                                    */
  41. /*    #include <TextEdit.h>                                        */
  42. #endif
  43. #ifndef __FILES__
  44.  
  45. #ifndef __FILES__
  46. #include <Files.h>
  47. #endif
  48. /*    #include <SegLoad.h>                                        */
  49. #endif
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55.  
  56. enum {
  57. /* resource IDs and item offsets of pre-7.0 dialogs */
  58.     putDlgID                    = -3999,
  59.     putSave                        = 1,
  60.     putCancel                    = 2,
  61.     putEject                    = 5,
  62.     putDrive                    = 6,
  63.     putName                        = 7,
  64.     getDlgID                    = -4000,
  65.     getOpen                        = 1,
  66.     getCancel                    = 3,
  67.     getEject                    = 5,
  68.     getDrive                    = 6,
  69.     getNmList                    = 7,
  70.     getScroll                    = 8,
  71. /* resource IDs and item offsets of 7.0 dialogs */
  72.     sfPutDialogID                = -6043,
  73.     sfGetDialogID                = -6042,
  74.     sfItemOpenButton            = 1,
  75.     sfItemCancelButton            = 2,
  76.     sfItemBalloonHelp            = 3,
  77.     sfItemVolumeUser            = 4,
  78.     sfItemEjectButton            = 5
  79. };
  80.  
  81. enum {
  82.     sfItemDesktopButton            = 6,
  83.     sfItemFileListUser            = 7,
  84.     sfItemPopUpMenuUser            = 8,
  85.     sfItemDividerLinePict        = 9,
  86.     sfItemFileNameTextEdit        = 10,
  87.     sfItemPromptStaticText        = 11,
  88.     sfItemNewFolderUser            = 12,
  89. /* pseudo-item hits for use in DlgHook */
  90.     sfHookFirstCall                = -1,
  91.     sfHookCharOffset            = 0x1000,
  92.     sfHookNullEvent                = 100,
  93.     sfHookRebuildList            = 101,
  94.     sfHookFolderPopUp            = 102,
  95.     sfHookOpenFolder            = 103,
  96. /* the following are only in system 7.0+ */
  97.     sfHookOpenAlias                = 104,
  98.     sfHookGoToDesktop            = 105,
  99.     sfHookGoToAliasTarget        = 106,
  100.     sfHookGoToParent            = 107,
  101.     sfHookGoToNextDrive            = 108,
  102.     sfHookGoToPrevDrive            = 109,
  103.     sfHookChangeSelection        = 110
  104. };
  105.  
  106. enum {
  107.     sfHookSetActiveOffset        = 200,
  108.     sfHookLastCall                = -2
  109. };
  110.  
  111. /* the refcon field of the dialog record during a
  112.  modalfilter or dialoghook contains one of the following */
  113.  
  114. #define sfMainDialogRefCon 'stdf'
  115.  
  116. #define sfNewFolderDialogRefCon 'nfdr'
  117.  
  118. #define sfReplaceDialogRefCon 'rplc'
  119.  
  120. #define sfStatWarnDialogRefCon 'stat'
  121.  
  122. #define sfLockWarnDialogRefCon 'lock'
  123.  
  124. #define sfErrorDialogRefCon 'err '
  125.  
  126. #if defined(powerc) || defined (__powerc)
  127. #pragma options align=mac68k
  128. #endif
  129. struct SFReply {
  130.     Boolean                            good;
  131.     Boolean                            copy;
  132.     OSType                            fType;
  133.     short                            vRefNum;
  134.     short                            version;
  135.     Str63                            fName;
  136. };
  137. #if defined(powerc) || defined(__powerc)
  138. #pragma options align=reset
  139. #endif
  140.  
  141. typedef struct SFReply SFReply;
  142.  
  143. #if defined(powerc) || defined (__powerc)
  144. #pragma options align=mac68k
  145. #endif
  146. struct StandardFileReply {
  147.     Boolean                            sfGood;
  148.     Boolean                            sfReplacing;
  149.     OSType                            sfType;
  150.     FSSpec                            sfFile;
  151.     ScriptCode                        sfScript;
  152.     short                            sfFlags;
  153.     Boolean                            sfIsFolder;
  154.     Boolean                            sfIsVolume;
  155.     long                            sfReserved1;
  156.     short                            sfReserved2;
  157. };
  158. #if defined(powerc) || defined(__powerc)
  159. #pragma options align=reset
  160. #endif
  161.  
  162. typedef struct StandardFileReply StandardFileReply;
  163.  
  164. typedef pascal short (*DlgHookProcPtr)(short item, DialogPtr theDialog);
  165. #if USESROUTINEDESCRIPTORS
  166. typedef UniversalProcPtr DlgHookUPP;
  167. #else
  168. typedef DlgHookProcPtr DlgHookUPP;
  169. #endif
  170.  
  171. enum {
  172.     uppDlgHookProcInfo = kPascalStackBased
  173.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  174.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  175.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr)))
  176. };
  177.  
  178. #if USESROUTINEDESCRIPTORS
  179. #define NewDlgHookProc(userRoutine)        \
  180.         (DlgHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDlgHookProcInfo, GetCurrentISA())
  181. #else
  182. #define NewDlgHookProc(userRoutine)        \
  183.         ((DlgHookUPP) (userRoutine))
  184. #endif
  185.  
  186. #if USESROUTINEDESCRIPTORS
  187. #define CallDlgHookProc(userRoutine, item, theDialog)        \
  188.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDlgHookProcInfo, (item), (theDialog))
  189. #else
  190. #define CallDlgHookProc(userRoutine, item, theDialog)        \
  191.         (*(userRoutine))((item), (theDialog))
  192. #endif
  193.  
  194. typedef pascal Boolean (*FileFilterProcPtr)(ParmBlkPtr PB);
  195. #if USESROUTINEDESCRIPTORS
  196. typedef UniversalProcPtr FileFilterUPP;
  197. #else
  198. typedef FileFilterProcPtr FileFilterUPP;
  199. #endif
  200.  
  201. enum {
  202.     uppFileFilterProcInfo = kPascalStackBased
  203.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  204.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ParmBlkPtr)))
  205. };
  206.  
  207. #if USESROUTINEDESCRIPTORS
  208. #define NewFileFilterProc(userRoutine)        \
  209.         (FileFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileFilterProcInfo, GetCurrentISA())
  210. #else
  211. #define NewFileFilterProc(userRoutine)        \
  212.         ((FileFilterUPP) (userRoutine))
  213. #endif
  214.  
  215. #if USESROUTINEDESCRIPTORS
  216. #define CallFileFilterProc(userRoutine, PB)        \
  217.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileFilterProcInfo, (PB))
  218. #else
  219. #define CallFileFilterProc(userRoutine, PB)        \
  220.         (*(userRoutine))((PB))
  221. #endif
  222.  
  223. /* the following also include an extra parameter of "your data pointer" */
  224.  
  225. typedef pascal short (*DlgHookYDProcPtr)(short item, DialogPtr theDialog, void *yourDataPtr);
  226. #if USESROUTINEDESCRIPTORS
  227. typedef UniversalProcPtr DlgHookYDUPP;
  228. #else
  229. typedef DlgHookYDProcPtr DlgHookYDUPP;
  230. #endif
  231.  
  232. enum {
  233.     uppDlgHookYDProcInfo = kPascalStackBased
  234.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  235.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  236.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr)))
  237.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*)))
  238. };
  239.  
  240. #if USESROUTINEDESCRIPTORS
  241. #define NewDlgHookYDProc(userRoutine)        \
  242.         (DlgHookYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDlgHookYDProcInfo, GetCurrentISA())
  243. #else
  244. #define NewDlgHookYDProc(userRoutine)        \
  245.         ((DlgHookYDUPP) (userRoutine))
  246. #endif
  247.  
  248. #if USESROUTINEDESCRIPTORS
  249. #define CallDlgHookYDProc(userRoutine, item, theDialog, yourDataPtr)        \
  250.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDlgHookYDProcInfo, (item), (theDialog), (yourDataPtr))
  251. #else
  252. #define CallDlgHookYDProc(userRoutine, item, theDialog, yourDataPtr)        \
  253.         (*(userRoutine))((item), (theDialog), (yourDataPtr))
  254. #endif
  255.  
  256. typedef pascal Boolean (*ModalFilterYDProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit, void *yourDataPtr);
  257. #if USESROUTINEDESCRIPTORS
  258. typedef UniversalProcPtr ModalFilterYDUPP;
  259. #else
  260. typedef ModalFilterYDProcPtr ModalFilterYDUPP;
  261. #endif
  262.  
  263. enum {
  264.     uppModalFilterYDProcInfo = kPascalStackBased
  265.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  266.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  267.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
  268.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short*)))
  269.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void*)))
  270. };
  271.  
  272. #if USESROUTINEDESCRIPTORS
  273. #define NewModalFilterYDProc(userRoutine)        \
  274.         (ModalFilterYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterYDProcInfo, GetCurrentISA())
  275. #else
  276. #define NewModalFilterYDProc(userRoutine)        \
  277.         ((ModalFilterYDUPP) (userRoutine))
  278. #endif
  279.  
  280. #if USESROUTINEDESCRIPTORS
  281. #define CallModalFilterYDProc(userRoutine, theDialog, theEvent, itemHit, yourDataPtr)        \
  282.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppModalFilterYDProcInfo, (theDialog), (theEvent), (itemHit), (yourDataPtr))
  283. #else
  284. #define CallModalFilterYDProc(userRoutine, theDialog, theEvent, itemHit, yourDataPtr)        \
  285.         (*(userRoutine))((theDialog), (theEvent), (itemHit), (yourDataPtr))
  286. #endif
  287.  
  288. typedef pascal Boolean (*FileFilterYDProcPtr)(ParmBlkPtr PB, void *yourDataPtr);
  289. #if USESROUTINEDESCRIPTORS
  290. typedef UniversalProcPtr FileFilterYDUPP;
  291. #else
  292. typedef FileFilterYDProcPtr FileFilterYDUPP;
  293. #endif
  294.  
  295. enum {
  296.     uppFileFilterYDProcInfo = kPascalStackBased
  297.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  298.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ParmBlkPtr)))
  299.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void*)))
  300. };
  301.  
  302. #if USESROUTINEDESCRIPTORS
  303. #define NewFileFilterYDProc(userRoutine)        \
  304.         (FileFilterYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileFilterYDProcInfo, GetCurrentISA())
  305. #else
  306. #define NewFileFilterYDProc(userRoutine)        \
  307.         ((FileFilterYDUPP) (userRoutine))
  308. #endif
  309.  
  310. #if USESROUTINEDESCRIPTORS
  311. #define CallFileFilterYDProc(userRoutine, PB, yourDataPtr)        \
  312.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileFilterYDProcInfo, (PB), (yourDataPtr))
  313. #else
  314. #define CallFileFilterYDProc(userRoutine, PB, yourDataPtr)        \
  315.         (*(userRoutine))((PB), (yourDataPtr))
  316. #endif
  317.  
  318. typedef pascal void (*ActivateYDProcPtr)(DialogPtr theDialog, short itemNo, Boolean activating, void *yourDataPtr);
  319. #if USESROUTINEDESCRIPTORS
  320. typedef UniversalProcPtr ActivateYDUPP;
  321. #else
  322. typedef ActivateYDProcPtr ActivateYDUPP;
  323. #endif
  324.  
  325. enum {
  326.     uppActivateYDProcInfo = kPascalStackBased
  327.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  328.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  329.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean)))
  330.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void*)))
  331. };
  332.  
  333. #if USESROUTINEDESCRIPTORS
  334. #define NewActivateYDProc(userRoutine)        \
  335.         (ActivateYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppActivateYDProcInfo, GetCurrentISA())
  336. #else
  337. #define NewActivateYDProc(userRoutine)        \
  338.         ((ActivateYDUPP) (userRoutine))
  339. #endif
  340.  
  341. #if USESROUTINEDESCRIPTORS
  342. #define CallActivateYDProc(userRoutine, theDialog, itemNo, activating, yourDataPtr)        \
  343.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppActivateYDProcInfo, (theDialog), (itemNo), (activating), (yourDataPtr))
  344. #else
  345. #define CallActivateYDProc(userRoutine, theDialog, itemNo, activating, yourDataPtr)        \
  346.         (*(userRoutine))((theDialog), (itemNo), (activating), (yourDataPtr))
  347. #endif
  348.  
  349. typedef OSType SFTypeList[4];
  350.  
  351. #ifdef __cplusplus
  352. extern "C" {
  353. #endif
  354. extern pascal void SFPutFile(Point where, ConstStr255Param prompt, ConstStr255Param origName, DlgHookUPP dlgHook, SFReply *reply)
  355.  THREEWORDINLINE(0x3F3C, 0x0001, 0xA9EA);
  356. extern pascal void SFGetFile(Point where, ConstStr255Param prompt, FileFilterUPP fileFilter, short numTypes, SFTypeList typeList, DlgHookUPP dlgHook, SFReply *reply)
  357.  THREEWORDINLINE(0x3F3C, 0x0002, 0xA9EA);
  358. extern pascal void SFPPutFile(Point where, ConstStr255Param prompt, ConstStr255Param origName, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc)
  359.  THREEWORDINLINE(0x3F3C, 0x0003, 0xA9EA);
  360. extern pascal void SFPGetFile(Point where, ConstStr255Param prompt, FileFilterUPP fileFilter, short numTypes, SFTypeList typeList, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc)
  361.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA9EA);
  362. extern pascal void StandardPutFile(ConstStr255Param prompt, ConstStr255Param defaultName, StandardFileReply *reply)
  363.  THREEWORDINLINE(0x3F3C, 0x0005, 0xA9EA);
  364. extern pascal void StandardGetFile(FileFilterUPP fileFilter, short numTypes, SFTypeList typeList, StandardFileReply *reply)
  365.  THREEWORDINLINE(0x3F3C, 0x0006, 0xA9EA);
  366. extern pascal void CustomPutFile(ConstStr255Param prompt, ConstStr255Param defaultName, StandardFileReply *reply, short dlgID, Point where, DlgHookYDUPP dlgHook, ModalFilterYDUPP filterProc, short *activeList, ActivateYDUPP activate, void *yourDataPtr)
  367.  THREEWORDINLINE(0x3F3C, 0x0007, 0xA9EA);
  368. extern pascal void CustomGetFile(FileFilterYDUPP fileFilter, short numTypes, SFTypeList typeList, StandardFileReply *reply, short dlgID, Point where, DlgHookYDUPP dlgHook, ModalFilterYDUPP filterProc, short *activeList, ActivateYDUPP activate, void *yourDataPtr)
  369.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA9EA);
  370. /* StandardOpenDialog uses the 'open' resource ID=128 in your application for the type list */
  371.  
  372. /* It runs on all versions of sytem software since System 4.2 */
  373.  
  374. extern pascal OSErr StandardOpenDialog(StandardFileReply *reply);
  375. extern void sfpputfile(Point *where, char *prompt, char *origName, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc);
  376. extern void sfgetfile(Point *where, char *prompt, FileFilterUPP fileFilter, short numTypes, SFTypeList typeList, DlgHookUPP dlgHook, SFReply *reply);
  377. extern void sfpgetfile(Point *where, char *prompt, FileFilterUPP fileFilter, short numTypes, SFTypeList typeList, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc);
  378. extern void sfputfile(Point *where, char *prompt, char *origName, DlgHookUPP dlgHook, SFReply *reply);
  379. /* 
  380.  
  381.   New StandardFile routine comments:
  382.  
  383.   activeList is pointer to array of integer (16-bits).
  384.   first integer is length of list.
  385.   following integers are possible activatable DITL items, in
  386.   the order that the tab key will cycle through.  The first
  387.   in the list is the item made active when dialog is first shown.
  388.  
  389.   activateProc is a pointer to a procedure like:
  390.  
  391.    PROCEDURE MyActivateProc(theDialog:  DialogPtr;
  392.           itemNo:  INTEGER;
  393.           activating: BOOLEAN;
  394.           yourDataPtr: Ptr);
  395.  
  396.   The activateProc is called with activating=FALSE on the itemNo
  397.   about to deactivate then with activating=TRUE on the itemNo
  398.   about to become the active item. (like activate event)
  399.  
  400.   yourDataPtr is a nice little extra that makes life easier without
  401.   globals.  CustomGetFile & CustomPPutFile when calling any of their
  402.   call back procedures, pushes the extra parameter of yourDataPtr on
  403.   the stack.
  404.  
  405.   In addition the filterProc in CustomGetFile & CustomPPutFile is called
  406.   before before SF does any mapping, instead of after.
  407. */
  408.  
  409. #ifdef __cplusplus
  410. }
  411. #endif
  412.  
  413. #ifdef __cplusplus
  414. }
  415. #endif
  416.  
  417. #endif /* __STANDARDFILE__ */
  418.